Have the gpx reader forward namespace declarations for http://www.w3.org/2001/XMLSche...
authortsteven4 <tsteven4@gmail.com>
Sat, 19 Dec 2015 18:27:24 +0000 (11:27 -0700)
committertsteven4 <tsteven4@gmail.com>
Sat, 19 Dec 2015 18:27:24 +0000 (11:27 -0700)
This avoids the problem of the gpx writer potentially using the prefix when it has not been declared.

19 files changed:
gpx.cc
reference/arc-project.gpx
reference/basecamp~gpx.gpx
reference/route/bend-input.gpx
reference/track/height.gpx
reference/track/i65.anr.gpx
reference/track/seg2trk_test.gpx
reference/track/simpletrack.gpx
reference/track/simplify-relative.gpx
reference/track/split-raw.gpx
reference/track/trackfilter_discard.gpx
reference/track/tracks.gpx
reference/track/trk_reverse_test-fwd.gpx
reference/transform-rte.gpx
reference/transform-wpt.gpx
reference/unknowntag2.gpx [new file with mode: 0644]
reference/unknowntag2~gpx.gpx [new file with mode: 0644]
reference/unknowntag~gpx.gpx
testo.d/gpx.test

diff --git a/gpx.cc b/gpx.cc
index f08dafb74eef2d9a41b4d3cab8122458e2ae8f20..0a62edd8bd66fd8c34740c345edf6ef8d8f6945d 100644 (file)
--- a/gpx.cc
+++ b/gpx.cc
@@ -469,7 +469,8 @@ tag_gpx(const QXmlStreamAttributes& attr)
   for (int i = 0; i < ns.size(); ++i) {
     QString prefix = ns[i].prefix().toString();
     QString namespaceUri = ns[i].namespaceUri().toString();
-    if (!prefix.isEmpty() && (0 != prefix.compare("xsi"))) {
+    /* don't toss any xsi declaration, it might used for tt_unknown or passthrough. */
+    if (!prefix.isEmpty()) {
       if (! gpx_namespace_attribute.hasAttribute(prefix.prepend("xmlns:"))) {
         gpx_namespace_attribute.append(prefix, namespaceUri);
       }
index b3061f381cb987da87dea6fe00eeecef3923b9ff..2f1f75896e30fbb1fe41c72c472f0782cc13400f 100644 (file)
@@ -2,9 +2,7 @@
 <gpx
   version="1.0"
   creator="GPSBabel - http://www.gpsbabel.org"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns="http://www.topografix.com/GPX/1/0"
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
+  xmlns="http://www.topografix.com/GPX/1/0">
 <time>1970-01-01T00:00:00Z</time>
 <bounds minlat="28.353803737" minlon="-16.502955209" maxlat="28.359546000" maxlon="-16.494318496"/>
 <wpt lat="28.357846000" lon="-16.499208000">
index 8687c233307b99b14bd9858f3964bd5b11d4f053..064f0533296a3a2a1db7e53ed880fead389e7ef1 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<gpx version="1.1" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:wptx1="http://www.garmin.com/xmlschemas/WaypointExtension/v1" xmlns:gpxtrx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:trp="http://www.garmin.com/xmlschemas/TripExtensions/v1" xmlns:adv="http://www.garmin.com/xmlschemas/AdventuresExtensions/v1" xmlns:prs="http://www.garmin.com/xmlschemas/PressureExtension/v1">
+<gpx version="1.1" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wptx1="http://www.garmin.com/xmlschemas/WaypointExtension/v1" xmlns:gpxtrx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:trp="http://www.garmin.com/xmlschemas/TripExtensions/v1" xmlns:adv="http://www.garmin.com/xmlschemas/AdventuresExtensions/v1" xmlns:prs="http://www.garmin.com/xmlschemas/PressureExtension/v1">
   <metadata>
     <time>1970-01-01T00:00:00Z</time>
     <bounds minlat="39.973869715" minlon="-105.498962402" maxlat="40.003967285" maxlon="-105.465850364"/>
index 5512d6e8bfb5a6e97445c22bfd6b801eee6afad2..9410909c304c7f0324ab3ee03404128dc3354a30 100644 (file)
@@ -2,9 +2,7 @@
 <gpx
   version="1.0"
   creator="GPSBabel - http://www.gpsbabel.org"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns="http://www.topografix.com/GPX/1/0"
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+  xmlns="http://www.topografix.com/GPX/1/0">
 <time>2011-11-15T17:50:48Z</time>
 <bounds minlat="43.439962900" minlon="-3.966600900" maxlat="43.493778700" maxlon="-3.790626500"/>
 <rte>
index 7836b1df52824e8c477da026122c8c09b999a4dd..d58df734615bdbf2ceda3a2d18bf69a5bb76470f 100644 (file)
@@ -2,9 +2,7 @@
 <gpx
   version="1.0"
   creator="GPSBabel - http://www.gpsbabel.org"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns="http://www.topografix.com/GPX/1/0"
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
+  xmlns="http://www.topografix.com/GPX/1/0">
 <time>1970-01-01T00:00:00Z</time>
 <bounds minlat="50.827089869" minlon="6.222871869" maxlat="50.865717758" maxlon="6.245795987"/>
 <trk>
index 32122b1321e7739218d81a0353ea3f8ec8601ed9..3ebb3ecb9126182182d46fb6b880dde050982c18 100644 (file)
@@ -2,9 +2,7 @@
 <gpx
   version="1.0"
   creator="GPSBabel - http://www.gpsbabel.org"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns="http://www.topografix.com/GPX/1/0"
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
+  xmlns="http://www.topografix.com/GPX/1/0">
 <time>2005-09-30T20:18:35Z</time>
 <rte>
   <name>Home to 8520 Northwe</name>
index 8ce0d0da70123fbeb26163eb2723ee32681d82e9..8edab96261f6d58281149771657f4a121a8b0bd2 100644 (file)
@@ -2,9 +2,7 @@
 <gpx
   version="1.0"
   creator="GPSBabel - http://www.gpsbabel.org"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns="http://www.topografix.com/GPX/1/0"
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
+  xmlns="http://www.topografix.com/GPX/1/0">
 <time>2012-12-03T07:53:56Z</time>
 <bounds minlat="46.943588000" minlon="14.156368000" maxlat="50.699530000" maxlon="19.226404000"/>
 <trk>
index d75d85c00e40306407d4d389ad05e6546a0e155a..c632083e822c1b129b3f8d07eef6b7c840976fd0 100644 (file)
@@ -2,9 +2,7 @@
 <gpx
   version="1.0"
 creator="GPSBabel - http://gpsbabel.sourceforge.net"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns="http://www.topografix.com/GPX/1/0"
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
+  xmlns="http://www.topografix.com/GPX/1/0">
 <time>2004-01-08T20:11:32Z</time>
 <trk>
 <trkseg>
index cb964cc0ef58aae3e2bed7b1df4190ce8eb5dfa0..17b29966346949d68fc18675b43b53e9d0d7dc5a 100644 (file)
@@ -2,9 +2,7 @@
 <gpx
   version="1.0"
   creator="GPSBabel - http://www.gpsbabel.org"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns="http://www.topografix.com/GPX/1/0"
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
+  xmlns="http://www.topografix.com/GPX/1/0">
 <time>2008-08-20T20:50:32Z</time>
 <bounds minlat="47.985856533" minlon="7.835891247" maxlat="47.989321947" maxlon="7.839775085"/>
 <trk>
index e346a1a9b02891e8aa60d3adec9fcc1a7117595a..74192766c48f1cd7925c5601830522093e089ecd 100644 (file)
@@ -2,9 +2,7 @@
 <gpx\r
   version="1.0"\r
   creator="GPSBabel - http://www.gpsbabel.org"\r
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
-  xmlns="http://www.topografix.com/GPX/1/0"\r
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">\r
+  xmlns="http://www.topografix.com/GPX/1/0">\r
 <time>2010-03-26T00:48:12Z</time>\r
 <bounds minlat="53.556432500" minlon="9.865178669" maxlat="53.556793494" maxlon="9.865555237"/>\r
 <trk>\r
index efe60fd959d35cf0fed323850ba3528ab2fb84ff..51b73acb42d5b14ce52a8788fd4291bd5adcc752 100644 (file)
@@ -2,9 +2,7 @@
 <gpx
   version="1.0"
   creator="GPSBabel - http://www.gpsbabel.org"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns="http://www.topografix.com/GPX/1/0"
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+  xmlns="http://www.topografix.com/GPX/1/0">
 <time>2012-04-17T08:26:58Z</time>
 <bounds minlat="-36.722941300" minlon="142.175800700" maxlat="-36.716685300" maxlon="142.198467900"/>
 <trk>
index 69f8fe78b00551be26a29cdef8ededdf312e027b..aecbb373a545f169ba31f64804c6a74c7ee6c1bd 100644 (file)
@@ -2,9 +2,7 @@
 <gpx
   version="1.0"
   creator="GPSBabel - http://www.gpsbabel.org"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns="http://www.topografix.com/GPX/1/0"
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
+  xmlns="http://www.topografix.com/GPX/1/0">
 <time>2007-02-14T15:24:42Z</time>
 <bounds minlat="30.045516667" minlon="-91.610566667" maxlat="30.062783333" maxlon="-91.589750000"/>
 <trk>
index 0be5ecb1b0a933b58f583c539b8160d36764b90f..09ac4fdcaa629e5e9b9ccea9db3bcce335944c64 100644 (file)
@@ -2,9 +2,7 @@
 <gpx
   version="1.0"
   creator="GPSBabel - http://www.gpsbabel.org"
-  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xmlns="http://www.topografix.com/GPX/1/0"
-  xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
+  xmlns="http://www.topografix.com/GPX/1/0">
 <time>1970-01-01T00:00:00Z</time>
 <bounds minlat="40.000000000" minlon="-106.300000000" maxlat="50.200000000" maxlon="-105.100000000"/>
 <trk>
index c7bb7d980c8f0d81d56b24cd1281d1cb2d5bfce7..f77673c83c49752ea793617b261644060d2e4c46 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<gpx version="1.1" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1">
+<gpx version="1.1" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <metadata>
     <time>1970-01-01T00:00:00Z</time>
     <bounds minlat="42.401051000" minlon="-71.126602000" maxlat="42.468655000" maxlon="-71.102973000"/>
index 1d510f22a395fd93ca211963ed42214aae7364e3..12745865c86fcb8e958a2c1762e3abc6e6772cb5 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<gpx version="1.1" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1">
+<gpx version="1.1" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <metadata>
     <time>1970-01-01T00:00:00Z</time>
     <bounds minlat="42.430950000" minlon="-71.122845000" maxlat="42.467110000" maxlon="-71.105116000"/>
diff --git a/reference/unknowntag2.gpx b/reference/unknowntag2.gpx
new file mode 100644 (file)
index 0000000..a5742bc
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
+<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="MapSource 6.12.2" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
+  <rte>
+    <name>B02222</name>
+    <extensions>
+      <gpxx:RouteExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xsi:schemaLocation="http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensions/v3/GpxExtensionsv3.xsd">
+        <gpxx:IsAutoNamed>false</gpxx:IsAutoNamed>
+      </gpxx:RouteExtension>
+    </extensions>
+    <rtept lat="47.6" lon="-112.0">
+      <name>A01111</name>
+      <desc>A St/B St</desc>
+      <sym>Waypoint</sym>
+      <extensions>
+        <gpxx:RoutePointExtension xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xsi:schemaLocation="http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensions/v3/GpxExtensionsv3.xsd">
+          <gpxx:Subclass>000000000000ffffffffffffffffffffffff</gpxx:Subclass>
+        </gpxx:RoutePointExtension>
+      </extensions>
+    </rtept>
+  </rte>
+</gpx>
diff --git a/reference/unknowntag2~gpx.gpx b/reference/unknowntag2~gpx.gpx
new file mode 100644 (file)
index 0000000..acdbbd0
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gpx version="1.1" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <metadata>
+    <time>1970-01-01T00:00:00Z</time>
+    <bounds minlat="47.600000000" minlon="-112.000000000" maxlat="47.600000000" maxlon="-112.000000000"/>
+  </metadata>
+  <rte>
+    <name>B02222</name>
+    <extensions>
+      <gpxx:RouteExtension xsi:schemaLocation="http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensions/v3/GpxExtensionsv3.xsd" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
+        <gpxx:IsAutoNamed>false</gpxx:IsAutoNamed>
+      </gpxx:RouteExtension>
+    </extensions>
+    <rtept lat="47.600000000" lon="-112.000000000">
+      <name>A01111</name>
+      <desc>A St/B St</desc>
+      <sym>Waypoint</sym>
+      <extensions>
+        <gpxx:RoutePointExtension xsi:schemaLocation="http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensions/v3/GpxExtensionsv3.xsd" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3">
+          <gpxx:Subclass>000000000000ffffffffffffffffffffffff</gpxx:Subclass>
+        </gpxx:RoutePointExtension>
+      </extensions>
+    </rtept>
+  </rte>
+</gpx>
index 25920f43e3683ed64cbc4a0901ae78dce084cdc4..eb7048524dc42f327cec1386563e9037ce5da1c2 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<gpx version="1.1" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1">
+<gpx version="1.1" creator="GPSBabel - http://www.gpsbabel.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <metadata>
     <time>1970-01-01T00:00:00Z</time>
     <bounds minlat="47.600000000" minlon="-112.000000000" maxlat="47.600000000" maxlon="-112.000000000"/>
index 70e7c327ed6b6ed89732eae6a512379886ec3ca2..0edb25d1f43ec244d09045b64b02b446b275b936 100644 (file)
@@ -40,3 +40,7 @@ compare ${REFERENCE}/basecamp~gpx.gpx ${TMPDIR}/basecamp~gpx_si.gpx
 rm -f ${TMPDIR}/unknowntag.gpx
 gpsbabel -i gpx -f ${REFERENCE}/unknowntag.gpx -o gpx -F ${TMPDIR}/unknowntag.gpx
 compare ${REFERENCE}/unknowntag~gpx.gpx ${TMPDIR}/unknowntag.gpx
+
+rm -f ${TMPDIR}/unknowntag2.gpx
+gpsbabel -i gpx -f ${REFERENCE}/unknowntag2.gpx -o gpx -F ${TMPDIR}/unknowntag2.gpx
+compare ${REFERENCE}/unknowntag2~gpx.gpx ${TMPDIR}/unknowntag2.gpx